cmake_minimum_required(VERSION 3.8)
project(adr_test)
# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)
include_directories(../src)



#获取所有测试cpp文件
file(GLOB_RECURSE SRC  
   "src/*.cpp"
   "../src/commonopr/common_opr_string.cpp"
    )

file(GLOB_RECURSE 3RD_SRC 
${CMAKE_CURRENT_SOURCE_DIR}/third/cJSON/*.c* )

# file(GLOB_RECURSE Source_Src ${CMAKE_CURRENT_SOURCE_DIR}/../src/*.c*)

set(ALL_COMPILE_SRC 
    ${SRC}
    ${3RD_SRC}
    # ${Source_Src}
    )

#获取所有h文件路径
file(GLOB_RECURSE INCLUDE  
    "src/*.h"
    "${CMAKE_CURRENT_SOURCE_DIR}/../src/*.h*"
    )
foreach(src ${INCLUDE})
    string(REGEX REPLACE "(.*)/.*h$" "\\1" include_path ${src})
    list(APPEND my_include_dirs ${include_path})
endforeach()

list(APPEND my_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/../third/)
list(REMOVE_DUPLICATES my_include_dirs)


# list(APPEND my_include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/unit_test/include/) 
include_directories(${my_include_dirs} ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_SOURCE_DIR}/../../release/soc/x86/usr/include/)
set(TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../)
include_directories(${TOP_SOURCE_DIR}/release/release/Release/x86_64/interface/drive_interface/include)

#unit_test 使用 private 转 public
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-access-control")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")


set(release_LIB_DIR     "${CMAKE_CURRENT_SOURCE_DIR}/../../release/soc/x86/usr/lib")
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../release/soc/x86/usr/lib ${CMAKE_CURRENT_SOURCE_DIR}/../output)

set(UT_NEED_LIBS protobuf;kutil;koption;jemalloc;yaml-cpp;gflags;ktime;fmt;clog;klog;glog)
add_executable(adr_test_ ${ALL_COMPILE_SRC})
target_link_libraries(adr_test_ ${UT_NEED_LIBS} gtest gmock pthread)
